package com.such.kit.validate.validator.impl;

import java.util.List;
import com.such.kit.string.StringCommons;
import com.such.kit.validate.validator.Validator;

/**
 * @author SUCH
 * <pre>
 * 数据长度范围校验器
 * 
 * [参数集说明]
 * 输入内容长度只能在范围内取值：#[1], #[2], #[3] ...
 * </pre>
 */
public class LengthRangeValidator extends Validator {

	@Override
	protected boolean checkParams(List<String> params) {
		if (params.size() > 0) {
			return true;
		}
		return false;
	}

	@Override
	protected boolean verify(String value, List<String> params) {
		String valueLen = String.valueOf(value.length());
		if (params.contains(valueLen)) {
			return true;
		}
		return false;
	}

	@Override
	protected String getVerifyMessage(List<String> params) {
		String message = StringCommons.merger("输入内容长度只能在范围内取值：", PARAMS_JSON_KEY);
		return message;
	}

}
